package org.seven.jrdp.commons.config;

import java.util.ResourceBundle;

import com.alibaba.druid.filter.config.ConfigTools;
import com.alibaba.druid.util.JdbcUtils;

public abstract class JdbcConfig {
	public static final String url;
	public static final String username;
	private static final String password;
	private static final String key;
	static {
		ResourceBundle bundle = ResourceBundle.getBundle("jdbc");
		url = bundle.getString("jdbc.url");
		username = bundle.getString("jdbc.username");
		password = bundle.getString("jdbc.password");
		key = bundle.getString("jdbc.key");
	}

	public static String getDbType() {
		return JdbcUtils.getDbType(url, null);
	}

	public static String getDriverClassName() {
		try {
			return JdbcUtils.getDriverClassName(url);
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}

	public static String getPassword() {
		try {
			return ConfigTools.decrypt(key, password);
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}
}